@extends('admin.main.layout')
@section('title', '短链接列表')
@section('content')
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <div>
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>短链接ID</th>
                                <th>用户ID</th>
                                <th>名称</th>
                                <th>到期时间</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($shortLists as $shortList)
                            <tr>
                                <td class="{{ $shortList->openid }}">{{ $shortList->short_id }}</td>
                                <td>{{ $shortList->openid }}</td>
                                <td>{{ $shortList->name }}</td>
                                <td><a href="{{ $shortList->link }}" target="_blank">长链接</a></td>
                                <td>{{ $shortList->created_at }}</td>
                                <td>
                                    <div style="display:flex;flex-direction: row;">
                                        <a href="javascript:;" class="text-primary" onclick="copyShortLink('{{ $shortList->short_link }}');"  style="margin-right:5px;">复制短链</a> | 
                                        <a href="javascript:;" onclick='mviewNotification("error","账号封禁提醒","封禁账号后，会删除对方全部链接，请确认是否封禁？","确认封禁","取消",{"type":"user_disable","openid":"{{ $shortList->openid }}"});' class="text-danger" style="margin:0 5px;">账号封禁</a>
                                    </div>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                <td colspan="7">当前暂无链接</td>
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
                <div class="">
                    <ul class="pagination">
                        {!! $shortLists->render() !!}
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="copylink" data-clipboard-text="" name=""></div>
<script type="text/javascript" src="/admin/js/short.min.js?v={{ time() }}"></script>
<script src="https://file.wailian1.cn/admin/js/public/clipboard.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        var copylink = new ClipboardJS('#copylink');
        copylink.on('success', function(e) {
            mviewToastr("success","链接复制成功，请粘贴获取链接!");
        });
    });

    function copyShortLink(short_link) {
        $('#copylink').attr("data-clipboard-text",short_link);
        $("#copylink").trigger("click");
    }
</script>
@endsection
